
#ifndef	CPLAYER_H
#define CPLAYER_H

#include "CBase.h"
//#include "CSpellBase.h"
#include "Messaging\IListener.h"

class CSpellBase;

enum {PLAYER_HEALTH_BAR, PLAYER_MANA_BAR, PLAYER_BAR_BORDER, PLAYER_SELF, PLAYER_NUM_IMAGE_ENUMS};	// image ID enums

class CPlayer : public CBase, public IListener
{
private:
	int		m_nHealth;			// how much health the player currently has
	int		m_nMaxHealth;		// the maximum health a player has in one life
	int		m_nMana;			// how much mana the player currently has
	int		m_nMaxMana;			// the maximum mana a player has in one life
	int		m_nNumLives;		// the number of lives the player currently has
	int		m_nSpeed;			// the player's current speed setting
	int		m_nBaseSpeed;		// the base speed of the player

	int		m_nNumSkeletons;	// The number of skeletons the player currently possesses
	int		m_nMaxSkeletons;	// The player may not have more than MaxSkeletons out at any given time

	int		m_nOwnerType;		// for use in checking what type of character owns a spell
	unsigned int m_unOMGroupID;	// the group that this object should be within the object manager
	int		m_nPlayerNumber;	// Is this player 1 or player 2?

	bool	m_bIsAlive;			// Is the player alive?
	bool	m_bHasArmor;		// Does the player currently have magic armor reduction?
	bool	m_bIsSlowed;		// Has the player been slowed by frost or slow hazards?
	bool	m_bIsEmpowered;		// Does the player currently deal double damage?
	bool	m_bHasARemoteMine;	// Does the player currently have a remote mine?
	bool	m_bHasADecoy;		// Does the player currently have a decoy?
	bool	m_bHasABarrier;		// Does the player currently have out a barrier?
	bool	m_bIsImmolating;	// Is the player immolating?
	bool	m_bIsSprinting;		// Does the player currently have the Sprint spell effect?
	bool	m_bHasASymbolOfFear;// Does the player currently have a symbol of fear?

	float	m_fDamageReduction;	// The player takes this much less damage (e.g. 0.30)

	float	m_fArmorCurrTime;	// The accumulated time since receiving magic armor
	float	m_fArmorTimer;		// The magic armor will last for this long
	float	m_fImmolationTime;	// The accumulated time since draining mana from the player. Reset after draining.
	float	m_fImmolationRate;	// Drain the player's mana every m_fImmolationRate seconds.
	float	m_fSprintTime;		// The accumulated time since casting the Sprint spell
	float	m_fSprintMaxTime;	// The Sprint spell wears off after this many seconds

	CSpellBase* spellSlot[4];	// contains the [up to] 4 spells the player may cast
	int		m_nImageID[PLAYER_NUM_IMAGE_ENUMS];

	// TODO: Images and animations
	// TODO: sound effects for death, etc. (spells will handle their own sounds)
public:
	// constructor
	CPlayer();

	// destructor
	~CPlayer();

	// update the player every frame
	void Update(float fElapsedTime);

	// show up on screen
	void Render(void);

	// draws buffs, debuffs, health and mana bars to the individual player's portion of the HUD
	void RenderHUD();

	// set default attributes
	void Reset();

	// check collision against all other objects 
	bool CheckCollision(IBaseInterface* pBase );

	void HandleEvent(CEvent* pEvent);

	/* accessors */
	// base stuff
	int GetHealth() const							{ return m_nHealth; }
	int GetMaxHealth() const						{ return m_nMaxHealth; }
	int GetMana() const								{ return m_nMana; }
	int	GetMaxMana() const							{ return m_nMaxMana; }
	int GetNumLives() const							{ return m_nNumLives; }	
	int GetSpeed() const							{ return m_nSpeed; }
	int GetBaseSpeed() const						{ return m_nBaseSpeed; }
	int GetOwnerType() const						{ return m_nOwnerType; }
	int GetPlayerNumber() const						{ return m_nPlayerNumber; }
	// skeletons
	int GetNumSkeletons() const						{ return m_nNumSkeletons; }
	int GetMaxSkeletons() const						{ return m_nMaxSkeletons; }
	// bools
	bool IsAlive() const							{ return m_bIsAlive; }	
	bool GetHasArmor() const						{ return m_bHasArmor; }
	bool GetIsSlowed() const						{ return m_bIsSlowed; }
	bool GetIsEmpowered() const						{ return m_bIsEmpowered; }
	bool GetIsImmolating() const					{ return m_bIsImmolating; }
	bool GetHasARemoteMine() const					{ return m_bHasARemoteMine; } 
	bool GetHasADecoy() const						{ return m_bHasADecoy; }
	bool GetHasABarrier() const						{ return m_bHasABarrier; }
	bool GetIsSprinting() const						{ return m_bIsSprinting; }
	bool GetHasASymbolOfFear() const				{ return m_bHasASymbolOfFear; }
	// floats
	float GetDamageReduction() const				{ return m_fDamageReduction; }
	// timers
	float GetArmorCurrTime() const					{ return m_fArmorCurrTime; }
	float GetArmorMaxTime() const					{ return m_fArmorTimer; }
	float GetImmolationTime() const					{ return m_fImmolationTime; }
	float GetImmolationRate() const					{ return m_fImmolationRate; }
	float GetSprintTime() const						{ return m_fSprintTime; }
	float GetSprintMaxTime() const					{ return m_fSprintMaxTime; }

	CSpellBase* GetSpellSlot(int index) const		{ return spellSlot[index]; }
	unsigned int  GetOMGroupID() const				{ return m_unOMGroupID; }
	int GetImageID(int index) const					{ return m_nImageID[index]; }
	

	/* mutators */
	// base info
	void SetHealth(int health)						{ m_nHealth = health; }
	void SetMaxHealth(int maxHealth)				{ m_nMaxHealth = maxHealth; }
	void SetMana(int mana)							{ m_nMana = mana; }
	void SetMaxMana(int maxMana)					{ m_nMaxMana = maxMana; }
	void SetNumLives(int lives)						{ m_nNumLives = lives; }
	void SetSpeed(int speed)						{ m_nSpeed = speed; }
	void SetBaseSpeed(int baseSpeed)				{ m_nBaseSpeed = baseSpeed; }
	void SetOwnerType(int ownerType)				{ m_nOwnerType = ownerType; }
	void SetPlayerNumber(int number)				{ m_nPlayerNumber = number; }

	// skeletons
	void SetNumSkeletons(int numSkeletons)			{ m_nNumSkeletons = numSkeletons; }
	
	// bools 
	void SetIsAlive(bool isAlive)					{ m_bIsAlive = isAlive; }
	void SetHasArmor(bool hasArmor)					{ m_bHasArmor = hasArmor; }
	void SetIsSlowed(bool isSlowed)					{ m_bIsSlowed = isSlowed; }
	void SetIsEmpowered(bool empowered)				{ m_bIsEmpowered = empowered; }
	void SetIsImmolating(bool isImmolating)			{ m_bIsImmolating = isImmolating; }
	void SetHasARemoteMine(bool hasAMine)			{ m_bHasARemoteMine = hasAMine; }
	void SetHasADecoy(bool hasADecoy)				{ m_bHasADecoy = hasADecoy; }
	void SetHasABarrier(bool hasABarrier)			{ m_bHasABarrier = hasABarrier; }
	void SetIsSprinting(bool isSprinting)			{ m_bIsSprinting = isSprinting; }
	void SetHasASymbolOfFear(bool hasSymbol)		{ m_bHasASymbolOfFear = hasSymbol; }

	void SetDamageReduction(float reduction)		{ m_fDamageReduction = reduction; }

	// timers
	void SetArmorCurrentTime(float time)			{ m_fArmorCurrTime = time; }
	void SetArmorMaxTime(float maxTime)				{ m_fArmorTimer = maxTime; }
	void SetImmolationTime(float accruedTime)		{ m_fImmolationTime = accruedTime; }
	void SetImmolationRate(float rate)				{ m_fImmolationRate = rate; }
	void SetAccruedSprintTime(float time)			{ m_fSprintTime = time; }
	void SetSprintMaxTime(float maxTime)			{ m_fSprintMaxTime = maxTime; }
		
	
	void SetSpellSlot(int index, CSpellBase* spell)	{ spellSlot[index] = spell; }
	void SetImageID(int index, int id)				{ m_nImageID[index] = id; }

};
#endif